package view;
/**
 *
 * @author zhaoyingxi
 */
import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Rectangle;
import javax.swing.JLabel;
import java.awt.Font;
import model.User;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


public class ViewContainer extends JFrame {
    private User user;
    public ViewContainer(User user) {
        this.user=user;
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        this.setTitle("AirLine Manager");
        getContentPane().setLayout(null);

        jButton1.setBounds(new Rectangle(42, 124, 122, 23));
        jButton1.setText("Book Ticket");
        jButton1.addActionListener(new ViewContainer_jButton1_actionAdapter(this));
        jButton3.setBounds(new Rectangle(373, 124, 128, 23));
        jButton3.setText("AirLine Manager");
        jButton3.addActionListener(new ViewContainer_jButton3_actionAdapter(this));
        jButton4.setBounds(new Rectangle(90, 182, 150, 23));
        jButton4.setText("AirPortInfo Manager");
        jButton4.addActionListener(new ViewContainer_jButton4_actionAdapter(this));
        jLabel1.setFont(new java.awt.Font("ZhaoYingxi", Font.PLAIN, 20));
        jLabel1.setText("User Login");
        jLabel1.setBounds(new Rectangle(187, 59, 177, 24));
        jButton5.setBounds(new Rectangle(295, 182, 150, 23));
        jButton5.setText("AirPortInfo");


        jButton5.addActionListener(new ViewContainer_jButton5_actionAdapter(this));
        jButton2.addActionListener(new ViewContainer_jButton2_actionAdapter(this));
        this.getContentPane().add(jLabel1);
        this.getContentPane().add(jButton2);
        this.getContentPane().add(jButton3);
        this.getContentPane().add(jButton1);
        this.getContentPane().add(jButton4);
        this.getContentPane().add(jButton5);
        this.setBounds(400,250,580,300);
        this.setResizable(false);
        jButton2.setBounds(new Rectangle(210, 124, 128, 23));
        jButton2.setText("Manager User");
        if(user.getStatus().equals("0"))
       {
           jButton2.setEnabled(false);
           jButton3.setEnabled(false);
           jButton4.setEnabled(false);
       }
       else if(user.getStatus().equals("1")){
           jButton3.setEnabled(false);
           jButton3.setEnabled(false);
          jButton4.setEnabled(false);
       }
       else if(user.getStatus().equals("2")){
           jButton2.setEnabled(false);
       }
    }

    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JButton jButton3 = new JButton();
    JButton jButton4 = new JButton();
    JLabel jLabel1 = new JLabel();
    JButton jButton5 = new JButton();
    //book
    public void jButton1_actionPerformed(ActionEvent e) {
        AirLineBookViewT airLineBookViewT = new  AirLineBookViewT();
    }

    public void jButton2_actionPerformed(ActionEvent e) {
        UserManagerViewT userManager = new UserManagerViewT();
    }

    public void jButton3_actionPerformed(ActionEvent e) {
        AirLineManagerViewT airLineManager = new  AirLineManagerViewT();
    }

    public void jButton4_actionPerformed(ActionEvent e) {
        AirPortInfoManagerViewT airPortInfo = new AirPortInfoManagerViewT();
    }

    public void jButton5_actionPerformed(ActionEvent e) {
        ViewAirPortInfoViewT viewInfo = new ViewAirPortInfoViewT();
    }
}


class ViewContainer_jButton5_actionAdapter implements ActionListener {
    private ViewContainer adaptee;
    ViewContainer_jButton5_actionAdapter(ViewContainer adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton5_actionPerformed(e);
    }
}


class ViewContainer_jButton4_actionAdapter implements ActionListener {
    private ViewContainer adaptee;
    ViewContainer_jButton4_actionAdapter(ViewContainer adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton4_actionPerformed(e);
    }
}


class ViewContainer_jButton3_actionAdapter implements ActionListener {
    private ViewContainer adaptee;
    ViewContainer_jButton3_actionAdapter(ViewContainer adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton3_actionPerformed(e);
    }
}


class ViewContainer_jButton2_actionAdapter implements ActionListener {
    private ViewContainer adaptee;
    ViewContainer_jButton2_actionAdapter(ViewContainer adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton2_actionPerformed(e);
    }
}


class ViewContainer_jButton1_actionAdapter implements ActionListener {
    private ViewContainer adaptee;
    ViewContainer_jButton1_actionAdapter(ViewContainer adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }
}
